package com.company4.students;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class ReadList {
    @SuppressWarnings("unchecked")
    public static List<student> readList() {
        ObjectInputStream in = null;
        List<student> listStudents =null;
        try {
            in = new ObjectInputStream(new FileInputStream("D:\\Homwork\\listStudents.txt"));
            Object obj = in.readObject();
            listStudents = (List<student>)obj;
        } catch (IOException | ClassNotFoundException e) {
            e.printStackTrace();
        } finally {
            if (null != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return listStudents;
    }
}
